package com.huiyeji.dynamic.core;

import java.util.List;

/**
 * @author Huiyeji
 */
public class DynamicStatementPointer {

    private final List<DynamicStatement> statements;

    private int currentPosition = -1;

    private final int size;

    public DynamicStatementPointer(List<DynamicStatement> statements) {
        this.statements = statements;
        this.size = statements.size();
    }

    public DynamicStatement next(){
        currentPosition ++;
        return get();
    }

    public boolean hasNext(){
        return currentPosition < size - 1;
    }

    public int getCurrentPosition(){
        return currentPosition;
    }

    public DynamicStatement get(){
        if (currentPosition >= size ){
            return null;
        }
        return statements.get(currentPosition);
    }

    public void setNextPosition(int position){
        currentPosition = position - 1;
    }

    public List<DynamicStatement> getStatements() {
        return statements;
    }

    public int getSize() {
        return size;
    }

    protected void reset() {
        currentPosition = -1;
    }
}
